
exports.connection= function(err,socket,session,manager){
    if (err || !session) {
        console.log("Error session socket");
        return;
    }

    console.log(session.cookie);
    socket.set("personage",session.user.personage);

}

exports.refresh = function(socket,session,manager){
    manager.getWorld().getMap({x : session.user.personage.coordinateX,
        y : session.user.personage.coordinateY}, 800, 800, function(territories){
        socket.emit('refresh', {
            territories : territories
        });
    });
}
/*
exports.reverseRefresh = function(center,radius,socket,manager,emitter){
    // getUser for radius

    // foreach user emitter new emmiter
    //
    socket.broadcast.emit("newUser",{ personnage : session.user.personage});
    world.getMap({x : session.user.personage.coordinateX,
        y : session.user.personage.coordinateY}, 800, 800, function(territories){
        socket.emit('refresh', {
            territories : territories,
            personages : self.personages
        });
    });
}


{

    self.personages.push(session.user.personage);

    socket.emit('init', {
        personage : session.user.personage
    });




    socket.on('disconnect', function () {
        console.log('END connection!!! ');
        self.removePerso(session.user.personage);
    });
});*/